<?php
/*
Template Name: Homepage 2
*/

//Retrieve all admin options.
global $options;
foreach ($options as $value) {
	if (get_option( $value['id'] ) === FALSE) { 
		$$value['id'] = $value['std']; 
	} else { 
		$$value['id'] = get_option( $value['id'] ); 
	}
}
?>

<?php get_header(); ?>

<!-- HOMEPAGE SLIDESHOW (start) -->		

<?php if( $jbobich_2_homepage_slideshow == 'showslideshow' ) : ?>

<script type="text/javascript">

	function paginate(idx, slide){	
		return '<a href="" title="" class="ie6"><img src="<?php bloginfo('template_directory'); ?>/layout/images/transparent.png" alt="" width="13" height="13" class="ie6" /></a>';
	}

	jQuery(document).ready(function() {
	
	    jQuery('#slideshow').cycle({
	        fx:     '<?php echo $jbobich_featured_transition; ?>',
	        timeout: <?php echo $jbobich_featured_autoplay_duration; ?>000,
	        pager:  '#slideshow-nav-inner',
	        pagerAnchorBuilder: paginate,
	        speed:  '2000',
	        easing: 'easeInOutQuint'
	    });
		    
	});

</script>

<div id="slideshow-wrapper">

	<div id="slideshow">
	
	<?php if($jbobich_2_homepage_taxonomy != 'all') { $slideshow = "&slideshows=".$jbobich_2_homepage_taxonomy; } ?>
	
	<?php query_posts('post_type=slide'.$slideshow); ?>
	
	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
	
		<?php
		$image = get_post_meta($post->ID, 'jaybichSlide-image', true);
		$link = get_post_meta($post->ID, 'jaybichSlide-link', true);
		?>
		
		<?php if($jbobich_image_crop == 'true') : ?>
		
		<!-- SHOW SLIDE w/Image Cropping -->
		<div>
			<?php if($link) : ?>
			<a href="<?php echo $link; ?>" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $image; ?>&amp;h=300&amp;w=960&amp;zc=1&amp;q=100&amp;cropfrom=<?php echo $jbobich_home_crop; ?>" alt="<?php the_title(); ?>" /></a>
			<?php else : ?>
			<img src="<?php echo $image; ?>" alt="<?php the_title(); ?>" />
			<?php endif; //END if link exists or not ?>
		</div>
		
		<?php else: ?>
		
		<!-- SHOW SLIDE w/out Image Cropping -->
		<div>
			<?php if($link) : ?>
			<a href="<?php echo $link; ?>" title="<?php the_title(); ?>"><img src="<?php echo $image; ?>" alt="<?php the_title(); ?>" /></a>
			<?php else : ?>
			<img src="<?php echo $image; ?>" alt="<?php the_title(); ?>" />
			<?php endif; //END if link exists or not ?>
		</div>
		<?php endif; //END if image cropping is on or off ?>
	
	<?php endwhile; else: ?>
		
		<p>No slides have been listed yet.</p>
	
	<?php endif; ?>
	
	</div><!-- #slideshow (end) -->
	
	<div id="slideshow-nav" class="ie6">
	
		<div id="slideshow-nav-inner"></div>

	</div><!-- #slideshow-nav(end) -->

</div><!-- #slideshow-wrapper (end) -->

<?php elseif( $jbobich_2_homepage_slideshow == 'htmlblock' ) : ?>

<div id="slideshow-wrapper">
	<div class="pad">
	
	<?php echo stripslashes($jbobich_2_homepage_custom_html); ?>
	
	</div><!-- .pad (end) -->
</div><!-- #slideshow-wrapper (end) -->

<?php endif; ?>

<?php wp_reset_query(); ?>

<!-- HOMEPAGE SLIDESHOW (end) -->


<!-- PRIMARY CONTENT (start) -->
		
<div id="primary" class="ie6">

	<div id="content">
	
		<div id="home-description">
			
			<?php the_post(); ?>
			
			<h2><?php the_title(); ?></h2>
		
			<?php the_content(); ?>
		
		</div><!-- #home-description (end) -->
	
		<div id="home-widget-area">
		
			<div class="widget">
				<div class="pad">
			
					<?php echo stripslashes($jbobich_2_homepage_box1); ?>
					
				</div><!-- .pad (end) -->			
			</div><!-- .widget (end) -->
			
			<div class="widget">
				<div class="pad">
			
					<?php echo stripslashes($jbobich_2_homepage_box2); ?>
				
				</div><!-- .pad (end) -->
			</div><!-- .widget (end) -->
		
			<div class="clear"></div>
		
		</div><!-- #home-widget-area (end) -->
	
	</div><!-- #content (end) -->
	
	<div id="sidebar">
	
		<div class="widget">
			
			<h2><?php echo stripslashes($jbobich_2_homepage_right_title); ?></h2>
			
			<?php
			if($jbobich_2_homepage_category != 'all') {
				$category = 'cat='.$jbobich_2_homepage_category.'&';
			}
			$query_string = $category.'showposts='.$jbobich_2_homepage_right_count; 
			query_posts($query_string);
			?>
			
			<?php while (have_posts()) : the_post(); ?>
			
			<h3><?php the_title(); ?></h3>
			<?php the_excerpt(); ?>
			<p class="read-more"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">READ MORE</a></p>
			
			<?php endwhile;?>
			
			<?php wp_reset_query(); ?>
						
		</div>
	
	</div><!-- #sidebar (end) -->	

<?php get_footer(); ?>